package com.kl.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kl.domain.LineLogisticsStoreDTO;
import com.kl.domain.LogisticsStoreDTO;
import com.kl.domain.LogisticsStoreDTOS;
import com.kl.em.ConstantEnum;
import com.kl.em.Result;
import com.kl.entity.LineLogisticsStore;
import com.kl.entity.LogisticsStore;
import com.kl.service.ILineLogisticsStoreService;
import com.kl.service.ILogisticsStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2021-11-02
 */
@RestController
@RequestMapping("/logisticsStore")
@Api(value = "网点查询接口")
public class LogisticsStoreController {
    @Autowired
    private ILogisticsStoreService logisticsStoreService;

    @ApiOperation(value = "网点查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "storeName", value = "地址模糊", required = true, paramType = "query"),
    })
    @GetMapping("/cityId")
    public Result<List<LogisticsStoreDTOS>> findById(@RequestParam String storeName) {
        QueryWrapper<LogisticsStore> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("city_id",Long.valueOf(storeName));
        //queryWrapper.like(true,);
        List<LogisticsStore> list = logisticsStoreService.list(queryWrapper);
        String s = JSONObject.toJSONString(list);
        List<LogisticsStoreDTOS> logisticsStoreDTOS = JSONObject.parseArray(s, LogisticsStoreDTOS.class);
        return Result.build(ConstantEnum.SUCCESS).setResult(logisticsStoreDTOS);
    }

}
